package lambdademo;

import java.util.Comparator;
import java.util.PriorityQueue;


//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}

//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}

//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}


//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}

//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}

public class Test {

    public static void main(String[] args) {
        int a = 99;
        MoreParameterReturn moreParameterReturn = (x,y)->{
            //a = 9999;
            System.out.println(a);
            return x+y;
        };
        System.out.println(moreParameterReturn.test(10, 20));


        /*OneParameterReturn oneParameterReturn = a -> a;
        System.out.println(oneParameterReturn.test(10));*/
/*
        NoParameterReturn noParameterReturn = ()->{return 10;};
*/
       /* NoParameterReturn noParameterReturn = ()-> 10;
        System.out.println(noParameterReturn.test());*/

    }

    public static void main3(String[] args) {
        /*NoParameterNoReturn noParameterNoReturn = ()->System.out.println("test.....");
        noParameterNoReturn.test();*/

        /*OneParameterNoReturn oneParameterNoReturn = (x) -> {
            System.out.println(x);
        };*/
        /*OneParameterNoReturn oneParameterNoReturn = x -> System.out.println(x);
        oneParameterNoReturn.test(10);*/

        /*MoreParameterNoReturn moreParameterNoReturn = (int x,int y) -> {
            System.out.println(x+y);
        };*/

        MoreParameterNoReturn moreParameterNoReturn = (x,y) ->  System.out.println(x+y);

        moreParameterNoReturn.test(10,20);

    }


    public static void main2(String[] args) {
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("test.....");
            }
        };
        noParameterNoReturn.test();

        System.out.println("====");

        NoParameterNoReturn noParameterNoReturn2 = ()->System.out.println("test.....");
        noParameterNoReturn2.test();


    }

    public static void main1(String[] args) {
        int a = 10;
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                // a = 20;
                System.out.println(a);
                return o1-o2;
            }
        });

        //a = 99;

        PriorityQueue<Integer> priorityQueue2 = new PriorityQueue<>(((x, o2) -> x-o2));

    }
}